<template>
    <el-row :gutter="20">
        <el-col :span="24">
            <el-steps :active="steps" finish-status="success" align-center style="margin: 15px 15px 0px !important">
                <el-step title="充值"></el-step>
                <el-step title="结账"></el-step>
                <el-step title="分配"></el-step>
            </el-steps>
        </el-col>
        <!-- 充值 -->
        <el-col :span="24" v-if="steps===0">
            <div class="block mb">
                <div class="block mb">
                    <el-autocomplete size="small" popper-class="my-autocomplete" v-model="ginfo.name" :fetch-suggestions="querySearch" placeholder="手机号或会员卡号" :trigger-on-focus="false" @select="handleSelect" :disabled="oinfo.status > -1">
                        <i class="el-icon-edit el-input__icon" slot="suffix"></i>
                        <template slot-scope="props">
                            <div><i class="el-icon-h-guke"></i> {{ props.item.name }}</div>
                            <span><i class="el-icon-h-vipcard"></i> {{props.item.vipcard}}</span>
                            <span><i class="el-icon-h-dianhua1"></i> {{ props.item.phone }}</span>
                        </template>
                    </el-autocomplete>
                    <el-tag v-if="ginfo.id">余额：{{ginfo.balance}}</el-tag>
                    <el-tag v-if="ginfo.id">赠送余额：{{ginfo.giftbalance}}</el-tag>
                    <el-tag v-if="ginfo.id">当前等级：{{ginfo.vipname}}</el-tag>
                    <el-input class="mt" type="textarea" v-model="ginfo.remarks" v-if="ginfo.id" placeholder="当前客户描述信息"></el-input>
                </div>
                <div class="block mb">
                    <el-input size="small" class="w200" v-model="done.balance" placeholder="请输入充值金额" :disabled="oinfo.status > 0" v-if="ginfo.id">
                        <template slot="prepend">充值</template>
                    </el-input>
                    <el-input size="small" class="w200" v-model="done.giftbalance" placeholder="充值赠送金额" :disabled="oinfo.status > 0" v-if="ginfo.id">
                        <template slot="prepend">赠送</template>
                    </el-input>
                    <el-select size="small" v-model="done.level" class="w150" v-if="ginfo.id" :disabled="oinfo.status > 0">
                        <el-option v-for="(l,index) in vips" :value="l.id" :label="l.vipname" :key="index"></el-option>
                    </el-select>
                    <el-select size="small" v-model="done.gdname" filterable @change="selGenDan" placeholder="请输入跟单人编号" :disabled="oinfo.status > 0" v-if="ginfo.id">
                        <el-option v-for="(g,index) in other.gendan" :label="g.worknum+g.name" :value="g" :key="index">{{g.name}}
                        </el-option>
                    </el-select>
                </div>
            </div>
            <div class="block">
                <el-alert title="如果充值有赠送产品和项目的话，可以在下面添加。先选择类型，在输入品项编号然后点击选择。" type="info" :closable="false">
                </el-alert>
                <el-table :data="done.giftPX">
                    <el-table-column label="类型">
                        <template slot-scope="scope">
                            <el-select size="mini" v-model="scope.row.type" placeholder="请选择品项类型" :disabled="scope.row.id!='' || oinfo.status > 0">
                                <el-option label="请选择品项类型" :value="0"></el-option>
                                <el-option label="产品" :value="1"></el-option>
                                <el-option label="项目" :value="2"></el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column prop="name" label="品项">
                        <template slot-scope="scope">
                            <el-select v-if="scope.row.type===1" size="mini" v-model="scope.row.name" filterable @change="selectPX(scope.row.name,scope.$index)" placeholder="产品编号" :disabled="oinfo.status > 0">
                                <el-option v-for="g in px.goods" :key="g.id" :label="g.number+g.name" :value="g">{{g.name}}
                                </el-option>
                            </el-select>
                            <el-select v-if="scope.row.type===2" size="mini" v-model="scope.row.name" filterable @change="selectPX(scope.row.name,scope.$index)" placeholder="项目编号" :disabled="oinfo.status > 0">
                                <el-option v-for="s in px.subject" :key="s.id" :label="s.number+s.name" :value="s">{{s.name}}
                                </el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column prop="price" label="原价">
                        <template slot-scope="scope"><span v-if="scope.row.type">{{scope.row.price+'元'}}</span></template>
                    </el-table-column>
                    <el-table-column prop="num" label="赠送数量">
                        <template slot-scope="scope">
                            <el-input size="mini" v-if="scope.row.type" v-model="scope.row.num" placeholder="赠送数量" :disabled="oinfo.status > 0">
                            </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="移除">
                        <template slot-scope="scope">
                            <el-button size="mini" type="danger" icon="el-icon-delete" v-if="scope.row.type" :disabled="oinfo.status > 0" @click="deleteRow(scope.$index,1)">
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-input type="textarea" class="mt" v-model="done.remarks" :disabled="oinfo.status > 0" placeholder="请输入充值描述信息">
                </el-input>
                <div class="block mt mb ov">
                    <el-button type="danger" icon="el-icon-close" @click="close">取消关闭</el-button>
                    <div class="block fr">
                        <el-button type="primary" icon="el-icon-d-arrow-right" @click="go(1)">保存订单并去结账</el-button>
                    </div>
                </div>
            </div>
        </el-col>
        <!-- 结账 -->
        <el-col :span="24" v-if="steps===1">
            <el-col :span="12">
                <el-alert title="收款账户列表" type="info" :closable="false">
                </el-alert>
                <!-- 收款账户列表 -->
                <el-table :data="submit.alist" class="mt">
                    <el-table-column prop="name" label="收款账户">
                        <template slot-scope="scope">
                            <el-select size="mini" v-model="scope.row.name" filterable placeholder="账户编号" @change="selectAcc(scope.row.name,scope.$index)" :disabled="scope.row.id != '' || oinfo.status > 0">
                                <el-option v-for="a in other.alist" :key="a.id" :label="a.number" :value="a">{{a.name}}
                                </el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column prop="money" label="应收金额">
                        <template slot-scope="scope">
                            <el-input size="mini" v-model="scope.row.money" placeholder="收款金额" v-if="scope.row.id" :disabled="oinfo.status > 0">
                            </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="移除">
                        <template slot-scope="scope">
                            <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteRow(scope.$index,2)" v-if="scope.row.id" :disabled="oinfo.status > 0">
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-tag size="mini" type="danger" class="fr">{{aMoney}}</el-tag>
            </el-col>
            <!-- 业绩分配和提成分配 -->
            <el-col :span="12">
                <el-alert title="业绩分配人员列表" type="info" :closable="false">
                </el-alert>
                <el-table :data="submit.ulist" class="mt">
                    <el-table-column prop="name" label="员工">
                        <template slot-scope="scope">
                            <el-select size="mini" v-model="scope.row.name" filterable placeholder="员工编号" @change="selectUser(scope.row.name,scope.$index)" :disabled="scope.row.id != '' || oinfo.status > 1">
                                <el-option v-for="a in other.ulist" :key="a.id" :label="a.worknum" :value="a">{{a.name}}
                                </el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column prop="money" label="业绩">
                        <template slot-scope="scope">
                            <el-input size="mini" v-model="scope.row.money" placeholder="业绩" v-if="scope.row.id" :disabled="oinfo.status > 1">
                            </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="移除">
                        <template slot-scope="scope">
                            <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteRow(scope.$index,3)" v-if="scope.row.id" :disabled="oinfo.status > 1">
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-tag size="mini" type="danger" class="fr">{{uMoney}}</el-tag>
            </el-col>
            <el-col :span="24" class="mt mb ov">
                <el-button type="primary" icon="el-icon-d-arrow-left" @click="goBack(0)">返回充值页面</el-button>
                <el-button type="danger" icon="el-icon-h-qiyong" @click="fanPay" :disabled="oinfo.status !== 1">反结账</el-button>
                <div class="block fr ov">
                    <el-button type="warning" icon="el-icon-h-bumen" @click="resetFenPei" :disabled="oinfo.status !== 1">重新分配业绩</el-button>
                    <el-button type="primary" icon="el-icon-d-arrow-right" @click="go(2)">前去分配提成</el-button>
                </div>
            </el-col>
        </el-col>
        <!-- 分配 -->
        <el-col :span="24" v-if="steps===2">
            <el-alert title="店家可根据业绩自定义分配提成金额，如果业绩分配不正确可到上一页重新分配业绩，如果分配不了，则点击下面的反分配，然后再去上一页重新分配业绩。如果下方反结账按钮不能点击，则表示当前订单未分配提成。" type="info" class="mb" :closable="false">
            </el-alert>
            <el-table :data="submit.tlist">
                <el-table-column prop="name" label="员工">
                    <template slot-scope="scope">
                        <el-select size="mini" v-model="scope.row.name" filterable placeholder="员工编号" @change="selectTicheng(scope.row.name,scope.$index)" :disabled="scope.row.id != '' || scope.row.addtype === 0">
                            <el-option v-for="a in other.ulist" :key="a.id" :label="a.worknum" :value="a">{{a.name}}
                            </el-option>
                        </el-select>
                    </template>
                </el-table-column>
                <el-table-column prop="money" label="业绩"></el-table-column>
                <el-table-column prop="ticheng" label="提成">
                    <template slot-scope="scope" v-if="scope.row.id">
                        <el-input v-model="scope.row.ticheng" size="mini" placeholder="提成金额"></el-input>
                    </template>
                </el-table-column>
                <el-table-column prop="addtype" label="类型">
                    <template slot-scope="scope" v-if="scope.row.id">
                        <el-tag size="mini" type="success" v-if="!scope.row.addtype">业绩提成</el-tag>
                        <el-tag size="mini" type="danger" v-else>其他提成</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="xianjinjieti" label="现金阶梯">
                    <template slot-scope="scope">
                        <el-tooltip class="item" effect="dark" placement="top" v-show="scope.row.addtype == 0">
                            <div slot="content">
                                <p v-for="items in scope.row.xianjinxinxi">{{items}}</p>
                            </div>
                            <el-input v-model="scope.row.xianjinjieti" size="mini" placeholder="提成金额"></el-input>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column label="移除">
                    <template slot-scope="scope" v-if="scope.row.id">
                        <el-button size="mini" type="danger" icon="el-icon-delete" :disabled="!scope.row.addtype" @click="deleteRow(scope.$index,4)"></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="block mb mt ov">
                <el-button type="primary" icon="el-icon-d-arrow-left" @click="goBack(1)">返回结账页面</el-button>
                <el-button type="danger" icon="el-icon-h-qiyong" @click="fanFenPei" :disabled="oinfo.status < 2">反分配</el-button>
                <div class="block fr">
                    <el-button type="success" icon="el-icon-check" @click="Finish">完成充值</el-button>
                </div>
            </div>
        </el-col>
    </el-row>
</template>
<script>
import C from '@/common/common.js'

export default {
  name: 'rechargeOrder',
  data () {
    return {
      steps: 0,
      ginfo: { name: '' },
      done: {
        balance: '',
        giftbalance: '',
        level: '',
        remarks: '',
        gdid: 0,
        gdname: '',
        giftPX: [{
          type: 0,
          id: 0,
          name: '',
          price: '',
          num: '',
          brandid: 0
        }]
      },

      glist: [],
      vips: [],

      loading: null,
      px: {
        goods: [],
        subject: [],
        loading: false
      },
      submit: {
        alist: [{
          id: 0,
          name: '',
          number: '',
          money: ''
        }],
        ulist: [{
          id: 0,
          name: '',
          worknum: '',
          money: '',
          bumenid: 0,
          xiaozuid: 0
        }],
        tlist: [{
          tid: 0,
          id: 0,
          name: '',
          worknum: '',
          money: '',
          ticheng: '',
          addtype: 1,
          bumenid: 0,
          xiaozuid: 0
        }]
      },
      other: {
        alist: [],
        ulist: [],
        basis: {},
        gendan: []
      },
      oinfo: { id: 0, status: -1 }
    }
  },
  methods: {
    /* 此为充值的一些控制操作 */
    async querySearch (queryString, cb) {
      if (/\d+/.test(queryString)) {
        let list = await C.ajax('/shop/recharge/queryguestlist', { query: queryString })
        if (list) {
          cb(list)
        }
      }
    },

    // 选择搜索后的客户信息
    handleSelect: function (item) {
      this.ginfo = item
      this.done.level = item.level
    },

    // 设置会员等级
    async getOrVips () {
      let list = await C.ajax('/shop/recharge/getvipgrade')
      if (list) {
        this.vips = list
      }
    },

    // 选择搜索后的品项
    selectPX (row, index) {
      let obj = {
        type: row.type,
        id: row.pxid,
        name: row.name,
        price: row.price,
        num: 1,
        brandid: row.brandid
      }

      this.done.giftPX[index] = obj
      this.$nextTick(() => {
        this.done.giftPX = JSON.parse(JSON.stringify(this.done.giftPX))
      })

      if (!this.done.giftPX[index + 1]) {
        this.initPx(1)
      }
    },

    // 选择跟单人（跟单人为管理层）
    selGenDan (row) {
      this.done.gdid = row.id
      this.done.gdname = row.name
    },

    // 删除赠送的品项行，收款账户行，业绩提成分配行
    deleteRow (index, tp) {
      if (tp === 1) {
        this.done.giftPX.splice(index, 1)
      } else if (tp === 2) {
        this.submit.alist.splice(index, 1)
      } else if (tp === 3) {
        this.submit.ulist.splice(index, 1)
      } else if (tp === 4) {
        this.submit.tlist.splice(index, 1)
      }
    },

    // 初始化选择，1：品项，2：账户，3：员工
    initPx (tp) {
      if (tp === 1) {
        this.done.giftPX.push({
          type: 0,
          id: '',
          name: '',
          price: '',
          num: '',
          brandid: 0
        })
      } else if (tp === 2) {
        this.submit.alist.push({
          id: 0,
          name: '',
          number: '',
          money: ''
        })
      } else if (tp === 3) {
        this.submit.ulist.push({
          id: 0,
          name: '',
          worknum: '',
          money: '',
          bumenid: 0,
          xiaozuid: 0
        })
        this.submit.tlist.push({
          id: 0,
          name: '',
          worknum: '',
          money: '',
          ticheng: '',
          addtype: 1,
          bumenid: 0,
          xiaozuid: 0
        })
      } else if (tp === 4) {
        this.submit.tlist.push({
          tid: 0,
          id: 0,
          name: '',
          worknum: '',
          money: '',
          ticheng: '',
          addtype: 1,
          bumenid: 0,
          xiaozuid: 0
        })
      }
    },

    // 初始加载时获取品项，并缓存到本地
    async sessionPx () {
      let list = await C.ajax('/shop/recharge/getalllist')
      if (list) {
        this.px.goods = list.goods
        this.px.subject = list.subject
        this.other.alist = list.alist
        this.other.ulist = list.ulist
        this.other.basis = list.basis

        let gendanrenlist = []
        list.ulist.forEach((u) => {
          if (u.ismanage) {
            gendanrenlist.push(u)
          }
        })

        this.other.gendan = gendanrenlist
      }
    },
    goBack (pos) {
      this.steps = pos
    },

    // 页面转换操作，tp=1为结账分配页面，tp=0为充值开单页面
    async go (tp) {
      let data = {}
      if (tp === 1) {
        // 开单操作
        if (this.done.balance == 0 && this.done.giftbalance == 0) {
          C.error('请选择客户并且输入充值金额、赠送金额')
          return false
        }
        if (this.done.giftPX.length) {
          let fh = false
          this.done.giftPX.forEach((v) => {
            if (v.id) {
              if (!/^([1-9]|[1-9]\d+)$/.test(v.num)) fh = true
            }
          })
          if (fh) {
            C.error('请输入赠送品项数量')
            return false
          }
        }
        // 判断是否跨店
        let crossShop = 0
        let shopid = JSON.parse(C.getLocalStorage('initConfig')).shopid
        if (this.ginfo.departmentid != 0 && shopid != this.ginfo.departmentid) {
          crossShop = 1
        }

        data = {
          oid: this.oinfo.id,
          gid: this.ginfo.id,
          gremarks: this.ginfo.remarks,
          bala: this.done.balance,
          gift: this.done.giftbalance,
          level: this.done.level,
          remarks: this.done.remarks,
          gdid: this.done.gdid,
          giftpx: this.done.giftPX,
          crossShop: crossShop
        }

        if (this.oinfo.status > 0) {
          this.steps = tp
          return false
        }
        let res = await C.ajax('/shop/recharge/goone', { data: JSON.stringify(data) }, 'post')
        if (res) {
          C.success(res.data.info)
          this.oinfo.id = res.data.orderid
          this.oinfo.status = res.data.status
          this.steps = tp
        }
      } else if (tp === 2) {
        // 结账操作
        if (this.aMoney != 0) {
          C.error('收款金额不正确')
          return false
        } else if (this.uMoney != 0) {
          C.error('业绩分配不正确')
          return false
        }
        let aalist = [],
          uulist = []

        this.submit.alist.forEach((a) => {
          if (a.id) {
            aalist.push(a)
          }
        })

        this.submit.ulist.forEach((u) => {
          if (u.id) {
            uulist.push(u)
          }
        })

        data = {
          oid: this.oinfo.id,
          alist: aalist,
          ulist: uulist
        }
        console.log(11)
        if (this.oinfo.status > 0) {
          this.ulist_tlist()
          this.initPx(4)
          this.steps = tp
        } else {
          let res = await C.ajax('/shop/recharge/gotwo', { data: JSON.stringify(data) }, 'post')
          if (res) {
            C.success(res.data.info)
            this.oinfo.status = res.data.status
            this.ulist_tlist()
            this.initPx(4)
            this.steps = tp
          }
        }
      }
    },

    /* 下面为结账控制时操作 */
    // 选择收款账户
    selectAcc (row, index) {
      let obj = {
        id: row.id,
        number: row.number,
        name: row.name,
        money: ''
      }
      this.submit.alist[index] = obj
      this.$nextTick(() => {
        this.submit.alist = JSON.parse(JSON.stringify(this.submit.alist))
      })

      if (!this.submit.alist[index + 1]) {
        this.initPx(2)
      }
    },

    // 选择业绩分配人员
    selectUser (row, index) {
      let obj = {
        id: row.id,
        worknum: row.worknum,
        name: row.name,
        money: '',
        bumenid: row.bumenid,
        xiaozuid: row.xiaozuid
      }
      let tObj = {
        id: row.id,
        name: row.name,
        addtype: 0,
        money: '',
        ticheng: '',
        bumenid: row.bumenid,
        xiaozuid: row.xiaozuid
      }
      this.submit.ulist[index] = obj
      this.submit.tlist[index] = tObj

      this.$nextTick(() => {
        this.submit.ulist = JSON.parse(JSON.stringify(this.submit.ulist))
        this.submit.tlist = JSON.parse(JSON.stringify(this.submit.tlist))
      })

      if (!this.submit.ulist[index + 1]) {
        this.initPx(3)
      }
    },

    // 选择分配其他提成员工
    selectTicheng (row, index) {
      let obj = {
        id: row.id,
        worknum: row.worknum,
        name: row.name,
        money: '',
        ticheng: '',
        addtype: 1,
        bumenid: row.bumenid,
        xiaozuid: row.xiaozuid
      }
      this.submit.tlist[index] = obj

      if (!this.submit.tlist[index + 1]) {
        this.initPx(4)
      }
    },

    // 重新分配业绩
    async resetFenPei () {
      if (this.uMoney * 1) {
        C.error('业绩分配不正确')
        return false
      }
      let ulist = [],
        isTrue = false
      this.submit.ulist.forEach((u) => {
        if (u.id) {
          ulist.push(u)
        }
        if (u.id && !u.money * 1 > 0) {
          isTrue = true
        }
      })

      if (isTrue) {
        C.error('请分配现金业绩')
        return false
      }

      let data = {
        oid: this.oinfo.id,
        ulist: ulist
      }
      C.confirm('确定重新分配现金业绩, 是否继续?', async () => {
        let res = await C.ajax('/shop/recharge/resetfenpei', { data: JSON.stringify(data) }, 'post')
        if (res) {
          C.success(res.data.info)
          this.ulist_tlist()
        }
      })
    },

    // 反结账操作
    fanPay () {
      C.confirm('反结账当前充值, 是否继续?', async () => {
        let res = await C.ajax('/shop/recharge/fanpay', { id: this.oinfo.id }, 'post')
        if (res) {
          C.success(res.data.info)
          this.oinfo.status = 0
        }
      })
    },

    // 反分配操作
    fanFenPei () {
      C.confirm('需要重新分配现金业绩, 是否继续?', async () => {
        let res = await C.ajax('/shop/recharge/fanfenpei', { id: this.oinfo.id }, 'post')
        if (res) {
          C.success(res.data.info)
          this.oinfo.status = res.data.status
        }
      })
    },

    // 确定充值操作
    async Finish () {
      let istc = false
      let tclist = []

      this.submit.tlist.forEach((t) => {
        if (t.id) {
          if (t.ticheng * 1 === 0 && t.money * 1 === 0) istc = true
          else tclist.push(t)
        }
      })

      if (istc) {
        C.error('提成金额不正确')
        return false
      }

      let retData = {
        oid: this.oinfo.id,
        tclist: tclist
      }

      if (this.oinfo.status > 1) {
        return C.closeBrowserWindow()
      }
      let res = await C.ajax('/shop/recharge/rechargeFinish', { retData: JSON.stringify(retData) }, 'post')
      if (res) {
        C.closeBrowserWindow(res)
      }
    },

    /* 公共操作 */
    close () {
      C.closeBrowserWindow()
    },

    tcRes () {
      this.$nextTick(() => this.tiChengRes)
    },

    async ulist_tlist () {
      if (this.submit.ulist.length > 1) {
        let newUlist = []
        // 向服务器请求数据
        let res = await C.ajax('/shop/recharge/getFeatInfo', { ulist: JSON.stringify(this.submit.ulist), id: this.oinfo.id })
        console.log(res)
        res.forEach((u) => {
          if (u.id) {
            u.ticheng = Number(u.money * this.other.basis.chongzhipercent).toFixed(2)
            u.addtype = 0
            newUlist.push(u)
          }
        })
        newUlist.push({
          fpid: 0,
          id: 0,
          name: '',
          addtype: 1,
          money: '',
          ticheng: 0,
          xianjinjieti: 0,
          xianjinxinxi: ''
        })

        this.submit.tlist = newUlist
      }
    }
  },
  computed: {
    tiChengRes () {
      if (this.submit.tlist.length > 1) {
        this.submit.tlist.forEach((t) => {
          t.ticheng = t.ticheng > 0 ? t.ticheng : Number(t.money * this.other.basis.chongzhipercent).toFixed(2)
        })
      }
    },
    aMoney () {
      if (this.submit.alist.length) {
        let syMoney = 0
        this.submit.alist.forEach((a) => {
          syMoney += a.money * 1
        })
        return Number(this.done.balance - syMoney).toFixed(2)
      }
    },
    uMoney () {
      if (this.submit.ulist.length) {
        let syMoney = 0
        this.submit.ulist.forEach((u) => {
          syMoney += u.money * 1
        })
        return Number(this.done.balance - syMoney).toFixed(2)
      }
    }
  },
  mounted: async function () {
    let that = this
    let Request = C.getDatas()
    this.sessionPx()
    this.getOrVips()

    if (Request.orderid) {
      let res = await C.ajax('/shop/recharge/getoinfo', { oid: Request.orderid })
      if (res) {
        res.oList.forEach((v) => {
          if (v.type === 4) {
            this.done.balance = v.price
            this.done.level = v.typeid
          }
          if (v.type === 5) {
            this.done.giftbalance = v.price
            this.done.level = v.typeid
          }
          if (v.type === 1 || v.type === 2) {
            this.done.giftPX.unshift({
              index: v.id,
              id: v.typeid,
              type: v.type,
              name: v.typename,
              price: v.price,
              num: v.num,
              brandid: v.brandid
            })
          }
        })

        // 如果状态为1，则为已结账已分配业绩。如果为2，则为已分配提成
        if (res.oInfo.status > -1) {
          res.aList.forEach((a) => {
            that.submit.alist.unshift({
              id: a.id,
              name: a.name,
              money: a.money
            })
          })
          res.uList.forEach((u) => {
            that.submit.ulist.unshift({
              id: u.userid,
              fpid: u.id,
              name: u.name,
              money: u.xianjinyeji,
              bumenid: u.bumenid,
              xiaozuid: u.xiaozuid
            })
          })
          if (res.oInfo.status > 0) {
            res.tList.forEach((t) => {
              that.submit.tlist.unshift({
                fpid: t.id,
                id: t.userid,
                name: t.name,
                addtype: t.addtype,
                money: t.xianjinyeji,
                ticheng: t.xianjinticheng,
                xianjinjieti: t.xianjinjieti,
                xianjinxinxi: t.xianjinxinxi
              })
            })
            this.tcRes()
            console.log(that.submit.tlist)
          }
        }

        this.oinfo = res.oInfo
        this.ginfo = res.gInfo

        this.done.gdid = res.oInfo.gendanid
        this.done.gdname = res.oInfo.name
        this.steps = res.oInfo.status
      }
    }

    if (Request.gid) {
      let info = await C.ajax('/shop/recharge/getguest', { gid: Request.gid })
      if (info) {
        this.done.level = info.level
        this.ginfo = info
      }
    }
  }
}
</script>
<style>
.ov {
  overflow: hidden;
}

.ov-x {
  overflow-x: hidden;
}

.fl {
  float: left;
}

.fr {
  float: right;
}

.clear {
  clear: both;
}

.none {
  display: none;
}

.block {
  display: block;
}

.handel {
  cursor: pointer;
}

/*背景颜色-前景颜色*/

.bg-dark {
  background: #f9fafc;
}

.bg-extra {
  background: #eff2f7;
}

.bg-light {
  background: #e5e9f2;
}

.bg-gray {
  background: #d3dce6;
}

.bg-silver {
  background: #8492a6;
}

.bg-black {
  background: #324057;
}

.white {
  color: white;
}

.black {
  color: #324057;
}

.green {
  color: green;
}

.blue {
  color: blue;
}

.red {
  color: red;
}

.color-nan {
  color: #2a91f7;
}

.color-nv {
  color: #f7992a;
}

/*其他样式*/

html {
  font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
    Microsoft YaHei, SimSun, sans-serif;
  font-weight: 400;
}

.title {
  font-size: 16px;
  font-family: 'Helvetica Neue', 'Helvetica', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  line-height: 26px;
  margin: 10px 0;
}

.border {
  border: 1px solid #dfe6ec;
  border-radius: 4px;
  padding: 0 8px;
}

.bd {
  border: 1px solid #dfe6ec;
}

.border-b {
  border-bottom: 1px solid #dfe6ec;
}

.border-t {
  border-top: 1px solid #dfe6ec;
}

.bd-l {
  border-left: 1px dashed #dfe6ec;
}

.bd-t {
  border-top: 1px dashed #dfe6ec;
}

.bd-r {
  border-radius: 50%;
}

.underline {
  text-decoration: underline;
}

/*边距*/

.p0 {
  padding: 0 !important;
}

.m0 {
  margin: 0 !important;
}

.m10 {
  margin: 10px !important;
}

.m15 {
  margin: 15px !important;
}

.p10 {
  padding: 10px !important;
}

.p15 {
  padding: 15px !important;
}

.ml {
  margin-left: 15px !important;
}

.mr {
  margin-right: 15px !important;
}

.mb {
  margin-bottom: 15px !important;
}

.mt {
  margin-top: 15px !important;
}

.pl {
  padding-left: 15px !important;
}

.pl0 {
  padding-left: 0 !important;
}

.pr {
  padding-right: 15px !important;
}

.pr0 {
  padding-right: 0 !important;
}

.pb {
  padding-bottom: 15px !important;
}

.pt {
  padding-top: 15px !important;
}

.center {
  text-align: center !important;
}

.left {
  text-align: left !important;
}

.right {
  text-align: right !important;
}

.w100 {
  width: 100px !important;
}

.w150 {
  width: 150px !important;
}

.w200 {
  width: 200px !important;
}

.w300 {
  width: 300px !important;
}

.w400 {
  width: 400px !important;
}

.w500 {
  width: 500px !important;
}

.w30 {
  width: 30%;
}

.w50 {
  width: 50%;
}

.width95 {
  width: 95%;
}

.width {
  width: 100% !important;
}

.h200 {
  height: 200px;
}

.h300 {
  height: 300px;
}

.h500 {
  height: 500px;
}

.h600 {
  height: 600px;
}

.h700 {
  height: 700px;
}

.h800 {
  height: 800px;
}

.l28 {
  line-height: 28px;
}

.l30 {
  line-height: 30px;
}

.l50 {
  line-height: 50px;
}

/*附加订制样式*/

.el-row {
  margin: 0 !important;
}

.el-table .cell {
  padding: 0;
  text-align: center;
}

.el-textarea__inner {
  resize: none;
}

.el-input.is-disabled .el-input__inner {
  color: #20a0ff;
}

.el-textarea.is-disabled .el-textarea__inner {
  color: #444;
}

.el-switch {
  line-height: 0;
}

.el-checkbox + .el-checkbox {
  margin-left: 0;
}

.el-checkbox {
  margin-right: 20px;
}

.el-autocomplete-suggestion li {
  padding: 4px 20px;
  line-height: 20px;
}

.el-table th {
  padding: 10px 0;
}

.el-table td {
  padding: 4px 0;
}
</style>